import type { ReactElement } from 'react';

import { vulnerabilitySeverityLabels } from 'messages/common';
import type { VulnerabilitySeverity } from 'types/cve.proto';

import SeverityIcons from '../SeverityIcons'; // TODO VulnerabilitySeverityIcons

import IconText from './IconText';

export type VulnerabilitySeverityIconTextProps = {
    severity: VulnerabilitySeverity;
    isTextOnly?: boolean;
};

function VulnerabilitySeverityIconText({
    severity,
    isTextOnly,
}: VulnerabilitySeverityIconTextProps): ReactElement {
    const Icon = SeverityIcons[severity];
    const text = vulnerabilitySeverityLabels[severity];

    return <IconText icon={<Icon />} text={text} isTextOnly={isTextOnly} />;
}

export default VulnerabilitySeverityIconText;
